using System;
using System.Collections.Generic;
using System.Text;
using Heaven.Mathematics;

namespace Heaven.Geometry.Procedural
{
    /// <summary>
    /// This is a class for a construction 
    /// which generates a polyline polygonal object
    /// </summary>
    public class Polyline : IProcedural
    {
       /// <summary>
        /// Generates polygonal object which represents the given polyline 
        /// (be aware to set proper technique to render wireframe objects)
        /// </summary>
        /// <param name="points">Points of this polyline</param>
        /// <returns>Polygonal object</returns>
        public static Polygonal GenerateWireframe(IEnumerable<Vector3> points)
        {
            Polygonal polygonal = new Polygonal();
            
            IEnumerator<Vector3> enumerator = points.GetEnumerator();
            if (!enumerator.MoveNext()) return polygonal;
            Vector3 previous = enumerator.Current;

            while(enumerator.MoveNext())
            {
                Vector3 current = enumerator.Current;
                polygonal.AddTriangle(new UnifiedVertex(previous), new UnifiedVertex(current), new UnifiedVertex(current));
                previous = current;
            }
 
            return polygonal;
        }

        #region Properties
        
        /// <summary>
        /// Thickness of this polyline (set zero to make 
        /// wireframe polyline, be aware to set proper 
        /// technique to render wireframe objects)
        /// </summary>
        public double Thickness = 1.0;
        
        #endregion

        #region Constructors

        /// <summary>
        /// Default constructor
        /// </summary>
        public Polyline() { }



        #endregion

        #region Generation

        /// <summary>
        /// Generates a polygonal model
        /// </summary>
        /// <returns>A model</returns>
        public Polygonal Generate()
        {
            return null;
        }

        #endregion
    }
}
